package com.kstech.ks_gaz01


import com.blankii.androidlibrary.utils.CRC16Util
import org.junit.Test

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun main2() {
        val x_fenge1 = ((305f / 905) * 600)
        println(x_fenge1)
    }
    @Test
    fun main1() {
        val map = HashMap<String, Boolean>()
        map.put("1", true)
        map.put("2", false)
        println(map["1"])
        println(map["3"])


    }


    @Test
    fun main() {
        val result =
            CRC16Util.getCRC(Hex2Byte("01 03 10 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08"))

        System.out.println("result:$result")
    }


    //16进制字符串转byte数组
    fun Hex2Byte(inHex: String): ByteArray? {
        val hex = inHex.split(" ".toRegex()).toTypedArray() //将接收的字符串按空格分割成数组
        val byteArray = ByteArray(hex.size)
        for (i in hex.indices) {
            //parseInt()方法用于将字符串参数作为有符号的n进制整数进行解析
            byteArray[i] = hex[i].toInt(16).toByte()
        }
        return byteArray
    }
}